/*
 * @Author: your name
 * @Date: 2020-03-30 21:00:54
 * @LastEditTime: 2020-03-30 21:00:55
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \vue-imooc-ebook\src\lang\index.js
 */
import Vue from 'vue'
import VueI18N from 'vue-i18n'
import en from './en'
import cn from './cn'
import { saveLocale, getLocale } from '../utils/localStorage'
// vue.use()应用插件
Vue.use(VueI18N)
const messages = {
  en,
  cn
}

let locale = getLocale()
if (!locale) {
  locale = 'cn'
  saveLocale(locale)
}

const i18n = new VueI18N({
  // 当前的语言
  locale,
  // 将语言对应的文本传入进来
  messages
})

export default i18n
// 到main.js中加载这个插件
